/*scanner for little programming language*/
%{
#include <cstdio>
#include <iostream>
using namespace std;
#define YY_DECL extern "C" int yylex()
#include "../generated/parser.tab.h"
%}
%option noyywrap

	int charcount=0,linecount=0;

%%
PROGRAM		{
	return PROGRAM;
}
BEGIN		{
	return BeGIN;
}
END			{
	return END;
}
ENDIF		{
	return ENDIF;
}
FUNCTION	{
	return FUNCTION;
}
READ		{
	return READ;
}
WRITE		{
	return WRITE;
}
IF			{
	return IF;
}
ELSIF		{
	return ELSIF;
}
DO			{
	return DO;
}
WHILE		{
	return WHILE;
}
CONTINUE	{
	return CONTINUE;
}
BREAK		{
	return BREAK;
}
RETURN		{
	return RETURN;
}
INT			{
	return INT;
}
VOID		{
	return VOID;
}
STRING		{
	return STRING;
}
FLOAT		{
	return FLOAT;
}
TRUE		{
	return TRUE;
}
FALSE		{
	return FALSE;
}
[a-zA-Z][a-zA-Z0-9]*	{
//	cout<<endl<<"!!!!!! identifier found: "<<yytext<<endl;
	yylval.idval=strdup(yytext);return IDENTIFIER;
	}
[0-9]+	{
//	cout<<endl<<"!!!!!! intliteral found: "<<yytext<<endl;
	yylval.ival=atoi(yytext);return INTLITERAL;
	}
[0-9]*"."[0-9]+	{
//	cout<<endl<<"!!!!!! floatliteral found: "<<yytext<<endl;
	yylval.fval=atof(yytext);return FLOATLITERAL;
	}
"\""(.+)"\""	{
//	cout<<endl<<"!!!!!! stringliteral found: "<<yytext<<endl;
	yylval.sval=strdup(yytext);return STRINGLITERAL;
	}
"-""-"(.+)

":="	{return ASSIGN;}
"+"	{return PLUS;}
"-"	{return MINUS;}
"*"	{return MULTIPLY;}
"/"	{return DIVIDE;}
"="	{return EQUAL;}
"!="	{return NEQUAL;}
"<"	{return LT;}
">"	{return GT;}
"("	{return LQ;}
")"	{return RQ;}
";"	{return SEMI;}
","	{return COMMA;}
"<="	{return LET;}
">="	{return GET;}
. 	charcount++;
\n	{linecount++; charcount++;}

%%

/*int main(argc,argv)
int argc;
char **argv;
{
	++argv, --argc;
	if (argc > 0)
		yyin=fopen(argv[0],"r");
	else
		yyin=stdin;
	yylex();
}
*/			
